package com.imut.lagain.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.imut.lagain.service.ICacheService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.time.Duration;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * 空缓存服务实现类，作为降级方案
 * 当Redis不可用时使用此实现
 */
@Service
@ConditionalOnMissingBean(ICacheService.class)
public class EmptyCacheServiceImpl implements ICacheService {
    private static final Logger log = LoggerFactory.getLogger(EmptyCacheServiceImpl.class);

    
    @Override
    public Boolean set(String key, Object value) {
        return false;
    }
    
    @Override
    public Boolean set(String key, Object value, long timeout, TimeUnit unit) {
        return false;
    }
    
    @Override
    public void set(String key, Object value, Duration duration) {
    }
    
    @Override
    public Object get(String key) {
        return null;
    }
    
    @Override
    public <T> T get(String key, Class<T> clazz) {
        return null;
    }
    
    @Override
    public String getString(String key) {
        return null;
    }
    
    @Override
    public Boolean setString(String key, String value) {
        return false;
    }
    
    @Override
    public Boolean setString(String key, String value, long timeout, TimeUnit unit) {
        return false;
    }
    
    @Override
    public Boolean setEx(String key, Object value, long seconds) {
        return false;
    }

    @Override
    public Boolean setStringEx(String key, String value, long seconds) {
        return null;
    }

    @Override
    public Boolean delete(String key) {
        return false;
    }
    
    @Override
    public Long delete(Collection<String> keys) {
        return 0L;
    }
    
    @Override
    public Boolean hasKey(String key) {
        return false;
    }
    
    @Override
    public Boolean expire(String key, long timeout, TimeUnit unit) {
        return false;
    }
    
    @Override
    public Boolean expire(String key, Duration timeout) {
        return false;
    }
    
    @Override
    public Long getExpire(String key) {
        return -1L;
    }
    
    @Override
    public Set<String> keys(String pattern) {
        return new HashSet<>();
    }
    
    @Override
    public Boolean hSet(String key, String hashKey, Object value) {
        return false;
    }
    
    @Override
    public Object hGet(String key, String hashKey) {
        return null;
    }
    
    @Override
    public <T> T hGet(String key, String hashKey, Class<T> clazz) {
        return null;
    }
    
    @Override
    public Long hDelete(String key, Object... hashKeys) {
        return 0L;
    }
    
    @Override
    public Boolean hHasKey(String key, String hashKey) {
        return false;
    }
    
    @Override
    public Map<Object, Object> hGetAll(String key) {
        return new HashMap<>();
    }
    
    @Override
    public Set<Object> hKeys(String key) {
        return new HashSet<>();
    }
    
    @Override
    public List<Object> hValues(String key) {
        return new ArrayList<>();
    }
    
    @Override
    public Long hSize(String key) {
        return 0L;
    }
    
    @Override
    public Boolean hMSet(String key, Map<String, Object> map) {
        return false;
    }
    
    @Override
    public Boolean hSetAll(String key, Map<String, Object> map) {
        return false;
    }

    @Override
    public List<Object> hMGet(String key, Collection<Object> hashKeys) {
        return List.of();
    }

    @Override
    public Long hIncr(String key, String field, long delta) {
        return 0L;
    }
    
    @Override
    public Long hIncr(String key, String field, int delta) {
        return 0L;
    }
    
    @Override
    public Long lLeftPush(String key, Object value) {
        return 0L;
    }
    
    @Override
    public Long lPush(String key, Object value) {
        return 0L;
    }
    
    @Override
    public Long lRightPush(String key, Object value) {
        return 0L;
    }

    @Override
    public Long rPush(String key, Object value) {
        return 0L;
    }

    @Override
    public Object lLeftPop(String key) {
        return null;
    }
    
    @Override
    public Object lRightPop(String key) {
        return null;
    }

    @Override
    public Object rPop(String key) {
        return null;
    }

    @Override
    public List<Object> lRange(String key, long start, long end) {
        return new ArrayList<>();
    }
    
    @Override
    public Long lSize(String key) {
        return 0L;
    }
    
    @Override
    public void lTrim(String key, long start, long end) {
    }
    
    @Override
    public Long sAdd(String key, Object... values) {
        return 0L;
    }
    
    @Override
    public Long sRemove(String key, Object... values) {
        return 0L;
    }
    
    @Override
    public Boolean sIsMember(String key, Object value) {
        return false;
    }
    
    @Override
    public Set<Object> sMembers(String key) {
        return new HashSet<>();
    }
    
    @Override
    public Long sSize(String key) {
        return 0L;
    }
    
    @Override
    public Boolean zAdd(String key, Object value, double score) {
        return false;
    }
    
    @Override
    public Long zRemove(String key, Object... values) {
        return 0L;
    }
    
    @Override
    public Set<Object> zRangeByScore(String key, double min, double max) {
        return new HashSet<>();
    }
    
    @Override
    public Set<Object> zRange(String key, long start, long end) {
        return new HashSet<>();
    }
    
    @Override
    public Long zSize(String key) {
        return 0L;
    }
    
    @Override
    public Double zScore(String key, Object value) {
        return null;
    }
    
    @Override
    public Long increment(String key) {
        return 0L;
    }
    
    @Override
    public Long increment(String key, long delta) {
        return 0L;
    }
    
    @Override
    public Long decrement(String key) {
        return 0L;
    }
    
    @Override
    public Long decrement(String key, long delta) {
        return 0L;
    }
    
    @Override
    public String generateKey(String prefix, String suffix) {
        return prefix + ":" + suffix;
    }
    
    @Override
    public void flushAll() {
    }
    
    @Override
    public Map<String, Object> getCacheInfo() {
        return new HashMap<>();
    }
    
    @Override
    public Map<String, Object> getInfo() {
        return new HashMap<>();
    }
    
    @Override
    public void cleanExpiredCache() {
    }
}
